package com.geovoice;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

/*    This file is part of Geovoice.

Geovoice is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Geovoice is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Geovoice.  If not, see <http://www.gnu.org/licenses/>.  */


/**
 * LocationsReceiver. This Receiver is Triggered on Bootup.
 * It checks the SharedPreferences to ensure Service and Startup
 * are enabled.  If so, the Background Service is launched 
 * at Bootup.
 */
public class LocationsReceiver extends BroadcastReceiver{
	

	
	/* (non-Javadoc)
	 * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
	 */
	@Override
	public void onReceive(Context context, Intent intent) {
		
		

		SharedPreferences preferences   = context.getSharedPreferences(Settings.PREFERENCENAME, 0);
        
		if(preferences.getBoolean(Settings.STARTUP_ENABLED, false))
			if(preferences.getBoolean(Settings.SERVICE_ENABLED, false)){
				Intent serviceIntent = new Intent(context,BackgroundService.class);
				context.startService(serviceIntent);
			}
	}
}


